import { defineStore } from 'pinia'

export const useGlobalStore = defineStore('global', {
  state: () => ({
    showLoginDialog: false,
    viewMode: localStorage.getItem('viewMode') || 'list',
    isMenuShow: true,
    isMenuAbsShow: false,
    postFilter: 0,
    postDetailMode: window.config_global.POST_DETAIL_MODE, // 帖子详情模式
    isPostDetailShow: false,
    isSocketOpen: false,
    heaserClickInfo:'',
    searchText:'',
    refreshollowPost: false,
    refreshFollower: false,
    isShowQuestionDialog: false,
  }),
  actions: {
    setPostDetailShow(isPostDetailShow) {
      this.isPostDetailShow = isPostDetailShow
    },
    setPostDetailMode(mode) {
      this.postDetailMode = mode
    },
    setRefreshollowPost(refreshollowPost) {
      this.refreshollowPost = refreshollowPost
    },
    setRefreshFollower(refreshFollower) {
      this.refreshFollower = refreshFollower
    },
    setPostFilter(filter) {
      this.postFilter = filter
    },
    setIsMenuShow(isMenuShow) {
      this.isMenuShow = isMenuShow
    },
    setIsMenuAbsShow(isMenuAbsShow) {
      this.isMenuAbsShow = isMenuAbsShow
    },
    toggleMenuAbsShow() {
      this.isMenuAbsShow = !this.isMenuAbsShow
    },

    setViewMode(mode) {
      this.viewMode = mode
      localStorage.setItem('viewMode', mode)
    },
    showLogin() {
      this.showLoginDialog = true
    },
    hideLogin() {
      this.showLoginDialog = false
    },
    setHeaderClickInfo(info){
      this.heaserClickInfo = info
    },
    setIsShowQuestionDialog(val){  
      this.isShowQuestionDialog = val
    },

    setSearchText(text){
      this.searchText = text
    }
  },
})
